{extend name="../application/index/view/index/base.html" /}

{block name="main-content"}
<!-- 导航栏开始 -->
<div class="breadcrumbs" id="breadcrumbs">
	<script type="text/javascript">
        try{ace.settings.check('breadcrumbs' , 'fixed')}catch(e){}
	</script>

	<ul class="breadcrumb">
		<li>
			<i class="icon-home home-icon"></i>
			<a href="#">权限控制</a>
		</li>
		<li class="active">用户组添加用户</li>
	</ul><!-- .breadcrumb -->

	<div class="nav-search" id="nav-search">
		<form class="form-search">
									<span class="input-icon">
										<input type="text" placeholder="Search ..." class="nav-search-input" id="nav-search-input" autocomplete="off" />
										<i class="icon-search nav-search-icon"></i>
									</span>
		</form>
	</div><!-- #nav-search -->
</div>
<!-- 导航栏结束 -->
<div style="margin: 15px;">
	<table class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<th width="10%" style="line-height: 33px;">
				搜索用户名：
			</th>
			<td>
				<form class="form-inline" action="">
					<input class="form-control" type="text" name="username" value="{$Think.get.username}" style="width: 70%;">
					<input style="display: none;" class="form-control" type="text" name="group_id" value="{$Request.get.group_id}">
					<input class="btn btn-success" type="submit" value="搜索" style="height: 33px;line-height: 14px;">
				</form>
			</td>
		</tr>
	</table>
	<table class="table table-striped table-bordered table-hover table-condensed">
		<tr>
			<th width="10%">用户名</th>
			<th>操作</th>
		</tr>
		{volist name="user_data" id="v"}
			<tr>
				<th>{$v['username']}</th>
				<td>
					{in name="$v['id']" value="$uids"}
						已经是{$group_name}
					{else/}
						<a href="javascript:" gid="{$group_id}" uid="{$v['id']}" onclick="add_user_to_group(this)">设为{$group_name}</a>
					{/in}
				</td>
			</tr>
		{/volist}

	</table>

</div>
<script>
    function add_user_to_group(obj){
        var gid=$(obj).attr('gid');
        var uid=$(obj).attr('uid');
        $.get('/index.php/index/auth/add_user_to_group',{"uid":uid,'group_id':gid},function (ret) {
            if(ret.code == 200){
                layer.msg('添加成功');
                location.reload();
            }else{
                layer.msg('添加失败');
            }
        });
    }
</script>
{/block}
